<template>
    <div class="Reviewlist">
        <mt-header fixed title="待审核列表">
            <mt-button icon="back" @click="backprev" slot="left"></mt-button>
        </mt-header>
        <mt-tab-container style="margin-top: 40px;" >
            <mt-tab-container-item>
                <div v-if="isIdCard" v-for="(n,index) in IdcardData">
                    <mt-cell  :title="'手机号 ' + n.mobile | capitalize"  :label="'昵称：'+n.nickname" >
                        <router-link  :to="{ path: '/reviewlistDetails', query: { id: n.userId , isIdCard : true, listdata : n }}">
                            <mt-button type="primary"  size="small">身份证审核</mt-button>
                        </router-link>
                    </mt-cell>
                </div>
                <div v-if="!isIdCard" v-for="(n,index) in carData">
                    <mt-cell  :title="'手机号 ' + n.mobile | capitalize"  :label="'昵称：'+n.userName">
                        <router-link  :to="{ path: '/reviewlistDetails', query: { id: n.carId , isIdCard : false, listdata : n }}">
                            <mt-button  type="danger"  size="small" style="margin-left: 10px;">行驶证审核</mt-button>
                        </router-link>
                    </mt-cell>
                </div>
            </mt-tab-container-item>
        </mt-tab-container>
    </div>
</template>

<script>
    import {
            authlist,
            back,
            loading,
            authcarlist
    } from '../common/api/api';
    export default {
        name: 'Reviewlist',
        data () {
            return {
                isIdCard : this.$route.query.isIdCard,
                IdcardData : [],
                carData : [],
                test:11,
            }
        },
        components: {
            //Hello
        },
        methods: {
            back : back,
            backprev : function () {
                this.$router.push('/selectreview');
            },
            initIdCard : function () {
                        var vm = this;
                        loading(true);
                        authlist({}, {
                            target: vm.createDialog
                        })
                        .then((result) => {
                            console.log(result);
                            if(result.errno == 0){
                                loading(false);
                                vm.IdcardData = result.data.data;
                            }else{
                                loading(false);
                                Toast(data.errmsg);
                            }

                        });
            },
            initCar : function () {
                var vm = this;
                loading(true);
                authcarlist({}, {
                    target: vm.createDialog
                })
                        .then((result) => {
                            console.log(result);
                            if(result.errno == 0){
                                loading(false);
                                vm.carData = result.data.data;
                            }else{
                                loading(false);
                                Toast(data.errmsg);
                            }

                        });
            }
        },
        created() {
            var vm = this;
            let isIdCard = vm.isIdCard;
            if(isIdCard){
                vm.initIdCard();
            }else{
                vm.initCar()
            }

        },
        filters: {
            capitalize: function (value) {
               if(!value || value == null || value == ""){
                   return "用户名不存在"
               }else{
                   return value
               }
            },
            toString : function (value) {
                console.log(value);
            }
        }

    }
</script>
